package com.example.myapplication2;

import android.content.Intent;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;

public class TextReception extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        System.out.println("...........");
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_text_reception);
        //获得分享
        //获取intent
        Intent intent4 =getIntent();
        String action = intent4.getAction();
        String type = intent4.getType();
        //设置接收类型为文本
        if (Intent.ACTION_SEND.equals(action) && type != null) {
            if ("text/plain".equals(type)) {
                Toast.makeText(this, "得到意图", Toast.LENGTH_SHORT).show();
                String data = intent4.getStringExtra(Intent.EXTRA_TEXT);
                Toast.makeText(this, data, Toast.LENGTH_SHORT).show();
            }
        }
    }
}